import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-06-16
 * Time: 21:42
 */
public class UdpDictServer extends UdpEchoServer{

    private HashMap<String, String> dict = new HashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);

        dict.put("你好", "hello");
        dict.put("早上好", "good morning");
        dict.put("晚上好", "good night");
        dict.put("再见", "bye");
        dict.put("小猫", "cat");
        dict.put("小狗", "dog");
        dict.put("小兔子", "rabbit");
    }

    @Override
    public String process (String request) {
        //查字典
        return dict.getOrDefault(request, "字典中暂无该词汇");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }

}
